<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ChatGroup extends Model
{
    use HasFactory;
    protected $fillable = [
        'inviter_id',
        'invitee_id',
    ];

    public function inviter()
    {
        return $this->belongsTo(ChatUser::class, 'inviter_id')->with(['related_table:id,name,avatar']);
    }
    
    public function invitee()
    {
    	return $this->belongsTo(ChatUser::class, 'invitee_id')->with(['related_table:id,name,avatar']);
    }
    
    public function message()
    {
    	return $this->hasMany(ChatGroupMessages::class);
    }
}
